package jtk.project4.fleet.field;

import java.awt.FlowLayout;

import jtk.project4.fleet.action.AddFuelReceiptAction;

import nl.coderight.jazz.action.Action;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.TableField;
import nl.coderight.jazz.form.field.TableField.AutoResizeMode;
import nl.coderight.jazz.form.field.button.PushButton;

public class InventoryReceiptField extends GroupControl<InventoryReceiptField>{

	private TableField<String>  partInventoryTable;
	private Action addFuelReceiptAction;
	
	public InventoryReceiptField(String bindID){
		createActions();
		setBindID(bindID);
		createFields();
		createLayout();
	}	
	
	private void createFields() {
		//setup table
		partInventoryTable = new TableField<String>("iventoryReceipts","iventoryReceipt");
		partInventoryTable.setAutoResizeMode(AutoResizeMode.ALL_COLUMNS);
		partInventoryTable.getSelectionValues();
		
		//add columns
		partInventoryTable.addColumn("label.qtyrcvd","qtyrcvd");
		partInventoryTable.addColumn("label.unitcost","unitcost");
		partInventoryTable.addColumn("label.datercvd","datercvd");
		partInventoryTable.addColumn("label.vendor","vendor");
	}
	
	private void createLayout() {
		// TODO Auto-generated method stub
		addField(createFieldGroup(),CENTER);
		addField(createButtons(),SOUTH);
	}
	
	
	private GroupControl createFieldGroup(){
		GroupControl fieldGroup=new GroupControl();
		fieldGroup.addField(partInventoryTable,CENTER);
		//fieldGroup.addField(new PushButton("add"), );
		return fieldGroup;
	}
	
	private GroupControl createButtons() {
		GroupControl buttons = new GroupControl();
		buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
		buttons.addField(new PushButton(addFuelReceiptAction), SOUTH);
		return buttons;
	}
	
	private void createActions(){
		addFuelReceiptAction = new AddFuelReceiptAction();
		
		//**********************************
	}
}
